def my_generator(data):
    for item in data:
        yield item

# 使用生成器
gen = my_generator([1, 2, 3, 4])
for item in gen:
    print(item)